/*****************************************************************************

                 ,//////,   ,////    ,///' /////,
                ///' ./// ///'///  ///,    ,, //
               ///////,  ///,///   '/// //;''//,
             ,///' '///,'/////',/////'  /////'/;,

    Copyright 2010 Marcus Jansson <mjansson256@yahoo.se>

    This file is part of ROSA - Realtime Operating System for AVR32.

    ROSA is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ROSA is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ROSA.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
/* Tab size: 4 */

#ifndef rosa_EXT_H_
#define rosa_EXT_H_

/// This file contains declarations for functions implemented in assembler.

#include "rosa_task.h"

/***********************************************************
 * Kernel low level context switch functions, implemented in rosa_ker_asm.S
 ***********************************************************/
extern void contextInit(tcb * tcbTask);
extern void contextRestore(void);
extern void contextSave(void);
extern void contextSaveFromISR(void);
extern void contextRestoreFromISR(void);
extern void ROSA_contextInit(tcb * tcbTask);
extern void ROSA_yield(void);

/// Sets the MCU to sleep mode 1
void ROSA_sleep(void);

/// Functions for saving and restoring the original execution context, 
/// so the scheduler can be stopped
extern void ROSA_restoreOriginalContext(void);
extern void ROSA_saveOriginalContext(void);

/// Returns the user stack pointer
extern int ROSA_getUserStackPointer(void);

//Start running the ROSA kernel
//This start running the created and installed tasks.
// Note: the EXECTASK pointer must point at the first task to run when 
// this function is called
extern void ROSA_start(void);

#endif /* rosa_EXT_H_ */
